luci-base: add odhcpd feature detection
authorDavid Härdeman <[email protected]>
Fri, 10 Oct 2025 12:54:11 +0000 (14:54 +0200)
committerPaul Donald <[email protected]>
Fri, 10 Oct 2025 17:04:07 +0000 (19:04 +0200)
For dnsmasq, feature detection is currently supported like this:

L.hasSystemFeature('dnsmasq', 'dhcpv6')

while for odhcpd, only a basic check is supported:

L.hasSystemFeature('odhcpd')

With this patch, a similar feature check is also possible for odhcpd,
e.g.:

L.hasSystemFeature('odhcpd', 'dhcpv6')

Signed-off-by: David Härdeman <[email protected]>
modules/luci-base/root/usr/share/rpcd/ucode/luci

index d32694788ad50e9a0468e711e84a3d1792980914..1e20634d4cd765530965865f26cb8bf20f729f77 100644 (file)
@@ -229,7 +229,6 @@ const methods = {
                                offloading: access('/sys/module/xt_FLOWOFFLOAD/refcnt') == true || access('/sys/module/nft_flow_offload/refcnt') == true,
                                br2684ctl:  access('/usr/sbin/br2684ctl') == true,
                                swconfig:   access('/sbin/swconfig') == true,
-                               odhcpd:     access('/usr/sbin/odhcpd') == true,
                                zram:       access('/sys/class/zram-control') == true,
                                sysntpd:    readlink('/usr/sbin/ntpd') != null,
                                ipv6:       access('/proc/net/ipv6_route') == true,
@@ -273,6 +272,25 @@ const methods = {
                                fd.close();
                        }
 
+                       result.odhcpd = false;
+                       fd = popen('odhcpd -h 2>/dev/null');
+
+                       if (fd) {
+                               const output = fd.read('all');
+
+                               if (output) {
+                                       result.odhcpd = {};
+                                       const m = match(output, /^Features: (.+)$/s);
+
+                                       for (let opt in split(m?.[1], ' ')) {
+                                               let f = replace(opt, 'no-', '', 1);
+                                               result.odhcpd[lc(f)] = (f == opt);
+                                       }
+                               }
+
+                               fd.close();
+                       }
+
                        // This check can be removed after v25 release
                        result.netifd_vrf = match(callPackageVersionCheck('netifd'), /^20[0-9][0-9]/s)?.[0] >= 2025;